package mainWindowSupport;
import javax.swing.*;

import java.awt.Dimension;

import javax.swing.JViewport;
import javax.swing.border.TitledBorder;


public class ShapeProperties {

	ShapePropTable shapePropTable;
	JScrollPane propertiesPane;
	JViewport currentView;

	public ShapeProperties() {
		initPane();
	}
	
	private void initPane() {
		propertiesPane = new JScrollPane();
		propertiesPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
		propertiesPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		propertiesPane.setPreferredSize(new Dimension(215,235));
		propertiesPane.setMinimumSize(new Dimension(10,0));
		TitledBorder titledBorder = BorderFactory.createTitledBorder("Shape Properties");
		titledBorder.setTitleJustification(TitledBorder.CENTER);
		titledBorder.setTitlePosition(TitledBorder.BELOW_TOP);
		propertiesPane.setBorder(titledBorder);
		
		currentView = new JViewport();
		//currentView.setView(shapePropTable.getCurrentTable());
		propertiesPane.setViewport(currentView);
	}
	
	public JScrollPane getPane() {
		return propertiesPane;
	}
	
	public void setView() {
		currentView.setView(shapePropTable.getCurrentTable());
		propertiesPane.setViewport(currentView);
		propertiesPane.updateUI();
	}
	
	public void setShapeTable(ShapePropTable propTable) {
		shapePropTable = propTable;
		JViewport tableView = new JViewport();
		tableView.setView(shapePropTable.getCurrentTable());
		propertiesPane.setViewport(tableView);
		propertiesPane.updateUI();
	}
	public void resetShapeTableView() {
		propertiesPane.setViewport(null);
	}
	public ShapePropTable getShapeTable() {
		return shapePropTable;
	}
}
